@extends('backstage.layout.master')
@section('title', '添加素材')
@section('style')
    <!-- page specific plugin styles -->
<link rel="stylesheet" href="assets/css/jquery-ui-1.10.3.custom.min.css"/>
<link rel="stylesheet" href="assets/css/chosen.css"/>
<link rel="stylesheet" href="assets/css/datepicker.css"/>
<link rel="stylesheet" href="assets/css/bootstrap-timepicker.css"/>
<link rel="stylesheet" href="assets/css/daterangepicker.css"/>
<link rel="stylesheet" href="assets/css/colorpicker.css"/>
<!-- fonts -->
@stop
@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a target="_blank" href="backstage/home">主页</a>
            </li>

            <li class="active">
                <a target="_blank" href="/backstage/source-pic/all">素材</a>
            </li>
            <li>
                添加素材
            </li>
        </ul><!-- .breadcrumb -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="page-header">
                    <h1>
                        素材
                        <small>
                            <i class="icon-double-angle-right"></i>
                            添加素材
                        </small>
                    </h1>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->

                        <form class="form-horizontal" role="form" action="/backstage/source-pic/add-source-pic" method="post" enctype="multipart/form-data">
                            <div class="form-group {{$errors->first('name')!=""?'has-error':''}}">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 素材名 </label>

                                <div class="col-sm-4">
                                    <input type="text" name="name" value="{{ old('name') }}" id="form-field-1" placeholder="素材名"
                                           class="width-100">
                                </div>
                                <div class="col-sm-5">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('name')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('image')!=""?'has-error':''}}">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                                    图片</label>

                                <div class="col-sm-4">
                                    <input type="file" id="image" name="image" placeholder="图片">
                                </div>
                                <div class="col-sm-5">
                                    <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('image')}}</div>
                                </div>
                            </div>
                            <div class="form-group ">
                                <label class="col-sm-3 control-label no-padding-right {{$errors->first('is_infinite_stock')!=""?'has-error':''}}" for="form-field-1">库存类型</label>
                                <div class="col-sm-4">
                                    <select name="is_infinite_stock" class="form-control" id="is_infinite_stock">
                                        <option @if(old('is_infinite_stock') === 1)selected @endif value=1>无限量</option>
                                        <option @if(old('is_infinite_stock') === 0)selected @endif value=0>有限量</option>
                                    </select>
                                </div>
                                <div class="col-sm-5">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('is_infinite_stock')}}</div>
                                </div>
                            </div>
                            <div class="space-4 stock" style="display: none;"></div>
                            <div class="form-group stock {{$errors->first('stock')!=""?'has-error':''}}" style="display: none;">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                                    库存</label>

                                <div class="col-sm-4">
                                    <input type="number" id="stock" name="stock" min=1 onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"placeholder="库存">
                                </div>
                                <div class="col-sm-5">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('stock')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group  {{$errors->first('price')!=""?'has-error':''}}">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                                    单件计价</label>
                                <div class="col-sm-4">
                                    <input type="number" id="price" name="price" step=0.01 min=0  placeholder="单价">
                                </div>
                                <div class="col-sm-5">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('price')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group ">
                                <label class="col-sm-3 control-label no-padding-right {{$errors->first('is_infinite_time')!=""?'has-error':''}}" for="form-field-1">库存类型</label>
                                <div class="col-sm-4">
                                    <select name="is_infinite_time" class="form-control" id="is_infinite_time">
                                        <option  value=0>有限时</option>
                                        <option selected  value=1>不限时</option>
                                    </select>
                                </div>
                                <div class="col-sm-5">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('is_infinite_time')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group on_sale {{$errors->first('shelf_time')!=""?'has-error':''}}" style="display: none">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                                    上架时间 </label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control"  name="shelf_time" id="form-field-8"
                                           placeholder="点击选择"/>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('shelf_time')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group ">
                                <label class="col-sm-3 control-label no-padding-right {{$errors->first('add_preferential')!=""?'has-error':''}}" for="form-field-1">库存类型</label>
                                <div class="col-sm-4">
                                    <select name="add_preferential" class="form-control" id="add_preferential">
                                        <option @if(old('add_preferential') === 0)selected @endif value=0>暂无优惠</option>
                                        <option @if(old('add_preferential') === 1)selected @endif value=1>添加优惠</option>
                                    </select>
                                </div>
                                <div class="col-sm-5">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('add_preferential')}}</div>
                                </div>
                            </div>
                            <div class="space-4 add_preferential_change" style="display: none"></div>
                            <div class="form-group add_preferential_change  {{$errors->first('preferential_stock')!=""?'has-error':''}}"style="display: none">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                                    优惠库存</label>
                                <div class="col-sm-4">
                                    <input type="number" id="preferential_stock" name="preferential_stock" min=1 onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"placeholder="库存">
                                </div>
                                <div class="col-sm-5">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('preferential_stock')}}</div>
                                </div>
                            </div>
                            <div class="space-4 add_preferential_change " style="display: none"></div>
                            <div class="form-group add_preferential_change  {{$errors->first('preferential_price')!=""?'has-error':''}}" style="display: none">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                                    优惠价</label>
                                <div class="col-sm-4">
                                    <input type="number" id="price" name="preferential_price" step=0.01 min=0  placeholder="优惠价">
                                </div>
                                <div class="col-sm-5">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('preferential_price')}}</div>
                                </div>
                            </div>
                            <div class="space-4 add_preferential_change" style="display: none"></div>
                            <div class="form-group add_preferential_change {{$errors->first('preferential_shelf_time')!=""?'has-error':''}}" style="display: none">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1">
                                    优惠时间 </label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control"  name="preferential_shelf_time" id="form-field-8"
                                           placeholder="点击选择"/>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('preferential_shelf_time')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group ">
                                <label class="col-sm-3 control-label no-padding-right {{$errors->first('all_temp_available')!=""?'has-error':''}}" for="form-field-1">适用模板</label>
                                <div class="col-sm-4">
                                    <select name="is_infinite_time" class="form-control" id="all_temp_available">
                                        <option  value=0>有限模板</option>
                                        <option selected  value=1>不限模板</option>
                                    </select>
                                </div>
                                <div class="col-sm-5">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('all_temp_available')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group prod_temp_search" style="display: none">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1">适用模板搜索</label>
                                <div class="col-xs-2">
                                    <input type="text"  value="" placeholder="模板关键字" class="width-100" id="prod_temp_keyword">
                                </div>
                                <div class="col-sm-5">
                                    <input  type="button" value="搜索" class="button" id="prod_temp_search">
                                    <select id="prod_temp_search_res"  onchange="resultChange(this.options,this.options.selectedIndex)"></select>
                                    <input type="button" name="add_range" value="+" class="button" onclick="addProdTemp()" />
                                </div>
                            </div>
                            <div class="form-group {{$errors->first('description')!=""?'has-error':''}}">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 参数简介</label>

                                <div class="col-sm-4">
                                    <textarea class="form-control" name="description" id="form-field-8"
                                              placeholder="简介">{{ old('description') }}</textarea>
                                </div>
                                <div class="col-sm-5">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('description')}}</div>
                                </div>
                            </div>
                            <div class="clearfix form-actions">
                                <div class="col-md-offset-3 col-md-9">
                                    <button class="btn btn-info" type="submit">
                                        <i class="icon-ok bigger-110"></i>
                                        保存
                                    </button>
                                </div>
                            </div>
                        </form>


                    </div><!-- /.col -->
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
@stop
@section('script')
    <script src="backstage/assets/js/date-time/bootstrap-datepicker.min.js"></script>
    <script src="backstage/assets/js/date-time/bootstrap-timepicker.min.js"></script>
    <script src="backstage/assets/js/date-time/moment.min.js"></script>
    <script src="backstage/assets/js/date-time/daterangepicker.min.js"></script>
    <script src="backstage/js/sourcePic/sourcePic.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#is_infinite_time').change(function () {
                var is_infinite_time=$(this).val();
                if(is_infinite_time==0){
                    $('.on_sale').show();
                }else {
                    $('.on_sale').hide();
                }
            });
            $('#is_infinite_stock').change(function () {
                var is_infinite_stock=$(this).val();
                if(is_infinite_stock==0){
                    $('.stock').show();
                }else {
                    $('.stock').hide();
                }
            });
            $('#add_preferential').change(function () {
                var add_preferential=$(this).val();
                console.log('添加优惠');
                console.log(add_preferential);
                if(add_preferential==0){
                    $('.add_preferential_change').hide();
                }else {
                    $('.add_preferential_change').show();
                }
            });
        });
    </script>
@stop
